<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function delay(ms) {
        // 你的代码
        return new Promise((resolve) => {
          setTimeout(() => {
            resolve();
          }, ms);
        });
      }
      /*
        ① delay(3000) 的返回值是一个带有then方法对象
      */
      delay(3000).then(() => {
        console.log("runs after 3 seconds");
      });
    </script>
  </body>
</html>
